<template>
  <div class="login-container">
    <el-card class="login-box">

      <template slot="header">
        <span class="wel">Welcome to Balance Bar</span>
      </template>
      <el-form >

        <!--        <el-form-group>-->
        <!--          <el-form-item label="用户名："  label-width="70px">-->
        <!--            <el-input v-model="form.username" placeholder="请输入用户名"></el-input>-->
        <!--          </el-form-item>-->
        <!--        </el-form-group>-->

        <!--        <el-form-group>-->
        <!--          <el-form-item label="密码：" label-width="70px">-->
        <!--            <el-input  type="password" v-model="form.password" placeholder="请输入密码"></el-input>-->
        <!--          </el-form-item>-->
        <!--        </el-form-group>-->

        <div class="right">
          <div class="username">
            <input type="text" name="username" id="username" value="" required=""  v-model="form.username">
            <label>Username</label>
          </div>
          <div class="pwd">
            <input type="password" name="pwd" id="pwd" value="" required=""  v-model="form.password">
            <label>Password</label>
          </div>
        </div>

        <el-form-group>
          <el-form-item >
            <el-button  type="success"  @click="loginHandle">LOGIN</el-button>
          </el-form-item>
        </el-form-group>

      </el-form>

    </el-card>
    <div v-show="errMsg.isShow">{{errMsg.message}}</div>
  </div>
</template>

<script>
  export default {
    name: "MyLogin",
    data(){
      return{
        form:{
          username:'' ,
          password:''
        },
        errMsg:{
          message:'用户名或密码错误',
          isShow:false
        }
      }
    },
    methods:{
      loginHandle(){
        //alert("username:"+this.form.username+" , password:"+this.form.password)
        var _this = this;
        this.axios({
          url: 'http://localhost:3000/user/login',
          method: 'get',
          params: {
            username: this.form.username,
            password: this.form.password
          }
        }).then(function (res) {
          if (res.data.flag){
            _this.$router.push('/layout')
          }else {
            _this.errMsg.isShow=true;
          }

        })
      }
    }
  }
</script>

<style scoped>
  .wel{
    margin-left: 30px;
    font-size: 33px;
    line-height: 50px;
    text-align: center;
    width: 230px;
    font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
    color: #fff;
    padding: 0 15px;
    font-weight: 300;

  }
  .login-container {
    background-image: url("login1.jpg");
    background-repeat: no-repeat;
    background-size: cover;
    position: fixed;
    height: 100%;
    width: 100%;
  }

  .login-box {
    width: 480px;
    margin-left: 33%;
    margin-top: 180px;
    background-image: linear-gradient(#1d2089, red);
    box-shadow: -11px 9px 11px 0px #A9A9A9;
    opacity: 0.7;
    border-radius: 12px;
    color: white;
    font-size: 1.2em;
    font-weight: bolder;
  }

  .el-button{
    margin-left: 170px;
    width: 20% ;
  }





  .right.username input:focus~label, .right.username input:valid~label,
  .right.pwd input:focus~label, .right.pwd input:valid~label{
    transform: translateY(-20px);
    left: 0;
    color: aqua;
    font-size: 14px;
  }

  .right{
    position: center;
    width: 100%;
    height: 100%;
    right: 0;
    top: 0;
    text-align: center;
  }
  .right .loginForm{
    width: 480px;
    height: 535px;
    margin: 50px auto 10px;
  }
  a{
    text-decoration: none;
    color: #ffffff;
  }


  .username,.pwd,.sign-in{
    position: relative;
  }
  .username label,.pwd label{
    position: absolute;
    top: 0;
    left: 0;
    padding: 10px 0;
    color: #8CD6D9;
    pointer-events: none;
    font: normal bolder 16px 'Microsort YaHei/微软雅黑';
    transition: 0.5s;
  }
  .username input,.pwd input{
    width: 100%;
    padding: 10px 0;
    font-size: 16px;
    /*color: #8CD6D9;*/
    margin-bottom: 30px;
    border: none;
    border-bottom: 1px solid #fff;
    outline: none;
    background:transparent;
    transition: 0.5s;
  }

  .right .username input:focus~label, .right .username input:valid~label,
  .right .pwd input:focus~label, .right .pwd input:valid~label{
    transform: translateY(-25px);
    left: 0;
    color: aqua;
    font-size: 14px;
  }
  .right .username input:focus,.right .username input:valid,
  .right .pwd input:focus, .right .pwd input:valid{
    border-bottom: 2px solid #79d2d2;
  }

</style>
